# _*_ coding utf-8 _*_
# FILENAME：main.py
# DESCRIPTION: 主界面逻辑模块
# AUTH: Jarvis
# DATE: 2022-5-23

from PyQt5 import QtWidgets

from views.bom.bomList import BomList
from views.factorytransporttime.factoryTransportTimeList import FactoryTransportTimeList
from views.inventory.inventoryList import InventoryList
import mainUI
from views.operationtime.operationTimeList import OperationTimeList
from views.orderplan.orderPlanList import OrderPlanList
from views.parts.partsList import PartsList
from views.partsloaddelaytime.partsLoadDelayTimeList import PartsLoadDelayTimeList
from views.producequeue.produceQueueList import ProduceQueueList
from views.producespeed.produceSpeedList import ProduceSpeedList
from views.require.requireList import RequireList
from views.requiresummary.requireSummaryList import RequireSummaryList
from views.schedule.scheduleList import ScheduleList
from views.shipper.shipperList import ShipperList
from views.supplieraddress.supplierAddressList import SupplierAddressList
from views.supplierdistance.supplierDistanceList import SupplierDistanceList
from views.supplierduration.supplierDurationList import SupplierDurationList


class MainWindow(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = mainUI.MainUI()
        self.ui.setupUi(self)
        # 关闭按钮事件绑定
        self.ui.left_close.clicked.connect(self.on_close_click)
        # 菜单-全部按钮点击
        self.ui.left_button_all.clicked.connect(self.on_menu_all_click)
        # 菜单-需求按钮点击
        self.ui.left_button_1.clicked.connect(self.on_require_click)
        # 菜单-排单按钮点击
        self.ui.left_button_2.clicked.connect(self.on_order_plan_click)
        # 菜单-零件信息按钮点击
        self.ui.left_button_3.clicked.connect(self.on_parts_click)
        # 菜单-供应商信息按钮点击
        self.ui.left_button_4.clicked.connect(self.on_suppliers_click)
        # 菜单-设置按钮点击
        self.ui.left_button_5.clicked.connect(self.on_config_click)
        '''零件需求'''
        self.ui.require_button_1.clicked.connect(self.on_require_bom_click)  # bom管理
        self.ui.require_button_2.clicked.connect(self.on_require_produce_queue_click)  # 生产队列管理
        self.ui.require_button_3.clicked.connect(self.on_require_produce_speed_click)  # 生产速度管理
        self.ui.require_button_4.clicked.connect(self.on_require_require_click)  # 零件需求汇总
        self.ui.require_button_5.clicked.connect(self.on_require_summary_click)  # 零件需求汇总
        '''排单管理'''
        self.ui.order_button_1.clicked.connect(self.on_order_plan_mg_click)  # 零件管理
        '''零件管理'''
        self.ui.parts_button_1.clicked.connect(self.on_parts_info_click)  # 零件管理
        self.ui.parts_button_2.clicked.connect(self.on_parts_LoadDelayTime_click)  # 零件装配延误时间管理
        self.ui.parts_button_3.clicked.connect(self.on_parts_inventory_click)  # 库存管理
        '''合作伙伴'''
        self.ui.suppliers_button_1.clicked.connect(self.on_suppliers_shipper_click)  # 承运商信息管理
        self.ui.suppliers_button_2.clicked.connect(self.on_suppliers_factoryTransportTime_click)  # 车辆在各点之间的运行时间管理
        self.ui.suppliers_button_3.clicked.connect(self.on_suppliers_operationTime_click)  # 作业时间管理
        self.ui.suppliers_button_4.clicked.connect(self.on_suppliers_address_click)  # 供应商地址
        self.ui.suppliers_button_5.clicked.connect(self.on_suppliers_distance_click)  # 供应商距离
        self.ui.suppliers_button_6.clicked.connect(self.on_suppliers_duration_click)  # 供应商路程时间
        '''基础设置'''
        self.ui.config_button_1.clicked.connect(self.on_config_shedule_click)  # 排班管理

    # 排单管理
    def on_order_plan_mg_click(self):
        self.baseWindow = OrderPlanList()
        self.baseWindow.show()

    # 作业时间管理
    def on_suppliers_operationTime_click(self):
        self.baseWindow = OperationTimeList()
        self.baseWindow.show()

    # 车辆在各点之间的运行时间管理
    def on_suppliers_factoryTransportTime_click(self):
        self.baseWindow = FactoryTransportTimeList()
        self.baseWindow.show()

    # 承运商信息管理
    def on_suppliers_shipper_click(self):
        self.baseWindow = ShipperList()
        self.baseWindow.show()

    # 供应商地址
    def on_suppliers_address_click(self):
        self.baseWindow = SupplierAddressList()
        self.baseWindow.show()

    # 供应商距离
    def on_suppliers_distance_click(self):
        self.baseWindow = SupplierDistanceList()
        self.baseWindow.show()

    # 供应商路程时间
    def on_suppliers_duration_click(self):
        self.baseWindow = SupplierDurationList()
        self.baseWindow.show()

    # 排班管理
    def on_config_shedule_click(self):
        self.baseWindow = ScheduleList()
        self.baseWindow.show()

    # 零件管理
    def on_parts_info_click(self):
        self.baseWindow = PartsList()
        self.baseWindow.show()

    # 零件装配延误时间管理
    def on_parts_LoadDelayTime_click(self):
        self.baseWindow = PartsLoadDelayTimeList()
        self.baseWindow.show()

    # 库存管理
    def on_parts_inventory_click(self):
        self.baseWindow = InventoryList()
        self.baseWindow.show()

    # 零件需求Bom管理事件
    def on_require_bom_click(self):
        self.baseWindow = BomList()
        self.baseWindow.show()

    # 零件需求生产队列管理事件
    def on_require_produce_queue_click(self):
        self.baseWindow = ProduceQueueList()
        self.baseWindow.show()

    # 零件需求生产速度管理事件
    def on_require_produce_speed_click(self):
        self.baseWindow = ProduceSpeedList()
        self.baseWindow.show()

    # 零件需求汇总事件
    def on_require_require_click(self):
        self.baseWindow = RequireList()
        self.baseWindow.show()

    # 零件需求汇总事件
    def on_require_summary_click(self):
        self.baseWindow = RequireSummaryList()
        self.baseWindow.show()

    # 关闭按钮
    def on_close_click(self):
        self.close()

    # 菜单-全部
    def on_menu_all_click(self):
        self.ui.right_require_label.setHidden(0)
        self.ui.right_order_label.setHidden(0)
        self.ui.right_parts_label.setHidden(0)
        self.ui.right_suppliers_label.setHidden(0)
        self.ui.right_config_label.setHidden(0)
        self.ui.right_require_widget.setHidden(0)
        self.ui.right_order_widget.setHidden(0)
        self.ui.right_parts_widget.setHidden(0)
        self.ui.right_suppliers_widget.setHidden(0)
        self.ui.right_config_widget.setHidden(0)
        self._hide()

    # 需求按钮点击事件btn_require click
    def on_require_click(self):
        self.ui.right_require_label.setHidden(0)
        self.ui.right_order_label.setHidden(1)
        self.ui.right_parts_label.setHidden(1)
        self.ui.right_suppliers_label.setHidden(1)
        self.ui.right_config_label.setHidden(1)
        self.ui.right_require_widget.setHidden(0)
        self.ui.right_order_widget.setHidden(1)
        self.ui.right_parts_widget.setHidden(1)
        self.ui.right_suppliers_widget.setHidden(1)
        self.ui.right_config_widget.setHidden(1)
        self._show()

    # 排单计划按钮点击事件btn_require click
    def on_order_plan_click(self):
        self.ui.right_require_label.setHidden(1)
        self.ui.right_order_label.setHidden(0)
        self.ui.right_parts_label.setHidden(1)
        self.ui.right_suppliers_label.setHidden(1)
        self.ui.right_config_label.setHidden(1)
        self.ui.right_require_widget.setHidden(1)
        self.ui.right_order_widget.setHidden(0)
        self.ui.right_parts_widget.setHidden(1)
        self.ui.right_suppliers_widget.setHidden(1)
        self.ui.right_config_widget.setHidden(1)
        self._show()

    # 零件信息按钮点击事件btn_require click
    def on_parts_click(self):
        self.ui.right_require_label.setHidden(1)
        self.ui.right_order_label.setHidden(1)
        self.ui.right_parts_label.setHidden(0)
        self.ui.right_suppliers_label.setHidden(1)
        self.ui.right_config_label.setHidden(1)
        self.ui.right_require_widget.setHidden(1)
        self.ui.right_order_widget.setHidden(1)
        self.ui.right_parts_widget.setHidden(0)
        self.ui.right_suppliers_widget.setHidden(1)
        self.ui.right_config_widget.setHidden(1)
        self._show()

    # 供应商按钮点击事件btn_require click
    def on_suppliers_click(self):
        self.ui.right_require_label.setHidden(1)
        self.ui.right_order_label.setHidden(1)
        self.ui.right_parts_label.setHidden(1)
        self.ui.right_suppliers_label.setHidden(0)
        self.ui.right_config_label.setHidden(1)
        self.ui.right_require_widget.setHidden(1)
        self.ui.right_order_widget.setHidden(1)
        self.ui.right_parts_widget.setHidden(1)
        self.ui.right_suppliers_widget.setHidden(0)
        self.ui.right_config_widget.setHidden(1)
        self._show()

    # 基础设置按钮点击事件btn_require click
    def on_config_click(self):
        self.ui.right_require_label.setHidden(1)
        self.ui.right_order_label.setHidden(1)
        self.ui.right_parts_label.setHidden(1)
        self.ui.right_suppliers_label.setHidden(1)
        self.ui.right_config_label.setHidden(0)
        self.ui.right_require_widget.setHidden(1)
        self.ui.right_order_widget.setHidden(1)
        self.ui.right_parts_widget.setHidden(1)
        self.ui.right_suppliers_widget.setHidden(1)
        self.ui.right_config_widget.setHidden(0)
        self._show()

    # 占位元素隐藏
    def _hide(self):
        self.ui.right_label_1.setHidden(1)
        self.ui.right_label_2.setHidden(1)
        self.ui.right_label_3.setHidden(1)
        self.ui.right_label_4.setHidden(1)
        self.ui.right_widget_1.setHidden(1)
        self.ui.right_widget_2.setHidden(1)
        self.ui.right_widget_3.setHidden(1)
        self.ui.right_widget_4.setHidden(1)

    # 占位元素显示
    def _show(self):
        self.ui.right_label_1.setHidden(0)
        self.ui.right_label_2.setHidden(0)
        self.ui.right_label_3.setHidden(0)
        self.ui.right_label_4.setHidden(0)
        self.ui.right_widget_1.setHidden(0)
        self.ui.right_widget_2.setHidden(0)
        self.ui.right_widget_3.setHidden(0)
        self.ui.right_widget_4.setHidden(0)

